﻿<%@ page language="java" pageEncoding="UTF-8" isELIgnored="false"%>
<%@page import="util.ServletHelp"%>
<%@page import="global.Constants"%>
<html>
<head>
	<%
		String superviseIds = request.getParameter("superviseIds");
	%>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<script type="text/javascript">
		$(document).ready(function(){
			var baseParams = {superviseIds:'<%=superviseIds%>'};
			var EXT_QUERY_TIME_OUT = 1200000;
			var superviseQueryStore;
			superviseQueryStore = new Ext.data.JsonStore({
		        url: '${pageContext.request.contextPath}/getSuperviseQuery.action',
		        root: 'datas',
				timeout : EXT_QUERY_TIME_OUT,
		        fields: ['id','superviseid','tel','calltime','answertime','disposition','endtime','context','supervise_status'],
		        baseParams: baseParams,
		        idProperty:'id',//唯一标识(如果不设定唯一标识,则多行记录只会显示一行记录)
		        autoLoad: true
		    });
		    
		    //工单类型
	        var superviseType = new Ext.data.ArrayStore({  
                    fields : ['superviseType', 'superviseTypeName'],  
		            data : <%=ServletHelp.getArrayFromMap(Constants.Supervise_TYPE_MAP, null)%>,
		            sortInfo: {field: "superviseType", direction: "ASC"}
	        });
		    
		    var supervisetypeQueryCombo = new Ext.form.ComboBox({
				id :'supervisetypeQueryCombo', 
				triggerAction: 'all', 
				typeAhead: true, 
				store: superviseType, 
				mode : 'local',
				valueField: 'superviseType', 
				displayField: 'superviseTypeName', 
				editable: true, 
				width:100,
				lazyRender: true,
				allowBlank:true
			});
		    
             // 用户数据表格
			var superviseQueryStore = new Ext.grid.GridPanel({
				id: 'superviseQueryStore',
				renderTo: 'superviseQueryStoreDiv',
				border: false,
				stateful: true,
			    autoScroll: 'auto',
		        store: superviseQueryStore,
		        loadMask: true,
		        cm: new Ext.grid.ColumnModel({
		            defaults: {
		                width: 100,
		                sortable: true
		            },
			        columns: [
						//new Ext.grid.RowNumberer({header:'№',width:50}),
						//{id:'id',header: '用户ID', width: 100, hidden: true, sortable: true, dataIndex: 'id'},
			            {id:'superviseid',header: '工单号', width: 100, sortable: true, dataIndex: 'superviseid'},
			            {id:'tel',header: '电话', width: 100, sortable: true, dataIndex: 'tel'},
			            {id:'calltime',header: '拨打时间', width: 150, sortable: true, dataIndex: 'calltime'},
			            {id:'answertime',header: '应答时间', width: 150, sortable: true, dataIndex: 'answertime'},
			            {id:'disposition',header: '是否接听', width: 100, sortable: true, dataIndex: 'disposition'},
			            {id:'endtime',header: '结束时间', width: 150, sortable: true, dataIndex: 'endtime'},
			            {id:'context',header: '通话内容', width: 150, sortable: true, dataIndex: 'context'},
			            {id:'supervise_status',header: '工单类型', width: 80, sortable: true, dataIndex: 'supervise_status',renderer: function(value, cellmeta,record){return typeComboRenderer(value, cellmeta,record);}}
					]
		        }),
		        columnLines: true
		    });
		    
		    // 设置Grid高度和宽度
		    Anynote.resizeGridTo("superviseQueryStore", 0, 56);
		    
		    // 类型ComboBox设值  
			function typeComboRenderer(value, cellmeta,record){
				var index = superviseType.find(Ext.getCmp('supervisetypeQueryCombo').valueField,value);
				var record = superviseType.getAt(index);
				var displayText = "";
				if(record==null){
					displayText = value;
				}else{
					displayText = record.data.superviseTypeName;
				}
				return displayText;
			}
		    
		 	// 取消按钮
		    $("#superviseQuery-cancel-button").click(function(){
		    	Ext.getCmp("buttonType").setValue("cancel");
		    	searchSuperviseWindow.close();
			});
		});
	</script>
</head>
<body> 
<div id="superviseQueryDiv" style="width:100%;height:100%;">
<div id="superviseQueryStoreDiv"></div>
</div>
</body>
</html>